#函数的嵌套

# def func(a):
#     print("开始")
#     def sum(a):
#         return a+2
#     def sub(a):
#         return a-2
#
#     if a>3:
#         return sum(a)
#     else:
#         return sub(a)
#
# print(func(2))
# print(func(4))
# print(sum(3)) #报错

# name = "xiaofeng"
# def run():
#     name = "小峰"
#     def inner():
#         print(name)
#     inner()
#
# run()


# name = "xiaofeng"
# def run():
#     name = "alex"
#     def inner():
#         print(name)
#     def test():
#         print("hello")
#     return [inner, test]
# func_list = run()
# func_list[0]()
# func_list[1]()

# name = '武沛齐'
# def func():
#     def inner():
#         print(name)
#     res = inner()
#     return res
# v = func()
# print(v)

# 武沛齐
# None

# name = '武沛齐'
#
# def func():
#     def inner():
#         print(name)
#         return "alex"
#     res = inner()
#     return res
#
# v = func()
# print(v)

# 武沛齐
# alex

# name = 'root'
#
# def func():
#     def inner():
#         print(name)
#         return 'admin'
#     return inner
#
# v = func()
# result = v()
# print(result)

# root
# admin

def func():
    name = '武沛齐'
    def inner():
        print(name)
        return '路飞'
    return inner

v11 = func()
data = v11()
print(data,id(data))


v2 = func()()
print(v2,id(v2))

